/*
 * Copyright 2010 Michael Nitsche
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.mnit.basis.swt.grafik.icon.direkt;

import de.mnit.basis.daten.struktur.schluessel.S_SchluesselListe;
import de.mnit.basis.daten.struktur.schluessel.SchluesselListe;
import de.mnit.basis.swt.grafik.icon.Icon;



/*
 * Es muß immer ein neues Bild vergeben werden, denn die Bilder werden teils automatisch freigegeben!
 */
public class ICON {

	private static ICON16 i16=null;
	private static ICON24 i24=null;
	private static ICON32 i32=null;

	public static final ICON16 _16= i16!=null ? i16 : (i16=new ICON16());
	public static final ICON24 _24= i24!=null ? i24 : (i24=new ICON24());
	public static final ICON32 _32= i32!=null ? i32 : (i32=new ICON32());

	private static S_SchluesselListe<String, Icon> flex=null;


	public static Icon gib(int groesse, String gruppe, String datei) {
		if(flex==null) flex=SchluesselListe.neu();
		String ident=gruppe+"/"+groesse+"/"+datei;
		Icon erg=null;
		if((erg=flex.gib(ident, null))!=null) return erg;
		erg = new Icon(groesse, gruppe, datei);
		flex.plus(ident, erg);
		return erg;
	}

	public static Icon gib(String jarpfad) {
		if(flex==null) flex=SchluesselListe.neu();
		Icon erg=null;
		if((erg=flex.gib(jarpfad, null))!=null) return erg;
		erg = new Icon(jarpfad);
		flex.plus(jarpfad, erg);
		return erg;
	}

}
